package com.xingkeduo.business.operation.service;

import com.xingkeduo.dao.database.DatabaseAccessObject;
import com.xingkeduo.pojo.query.PackageUpdateQuery;
import com.xingkeduo.pojo.table.PackageUpdateTable;
import com.xingkeduo.util.pojo.exception.DataException;
import com.xingkeduo.util.tool.CommonUtil;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * 类说明  安装包更新service
 *
 * @author: pantong E-mail:pantong@xingkeduo.com
 * @date: 2019年6月15日 下午2:03:37
 */
@Component
public class PackageUpdateService {
    private static final String NAMESPACE = PackageUpdateTable.class.getSimpleName();

    @Resource(name = "mysqlOperationDao")
    private DatabaseAccessObject<PackageUpdateTable, PackageUpdateQuery> dao;


    //查询多条
    public List<PackageUpdateTable> selectLists(PackageUpdateQuery packageUpdateQuery) throws Throwable {
        List<PackageUpdateTable> packageUpdateTableList = dao.select(NAMESPACE, packageUpdateQuery);
        if (!CommonUtil.isEmpty(packageUpdateTableList))
            return packageUpdateTableList;
        return null;
    }

    /**
     * 修改
     *
     * @param packageUpdateTable:
     * @return : void
     * @author : gaozifeng
     * @date : 2019/6/26 15:01
     */
    public void update(PackageUpdateTable packageUpdateTable) throws Throwable {
        int update = dao.update(NAMESPACE, packageUpdateTable);
        if (update == 0) {
            throw new DataException(DataException.Type.FAIL, "修改");
        }
    }

}
